package cn.me.alphamq.nameserver.event.model.service;

import cn.me.alphamq.common.entity.req.ServiceRegistryReq;
import cn.me.alphamq.common.enumeration.ServiceInstanceTypeEnum;
import cn.me.alphamq.common.event.model.Event;

import java.util.Map;

/**
 * 注册事件（producer、consumer、broker 首次连接 nameserver 时会发生该事件）
 *
 * @author f
 */
public class RegistryEvent extends Event {

    /**
     * 注册的服务实例的类型
     *
     * @see ServiceInstanceTypeEnum
     */
    private String serviceInstanceType;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 本服务实例 的 ip 地址
     */
    private String ip;

    /**
     * 本服务实例 的 端口号
     */
    private Integer port;

    /**
     * 服务实例的属性
     */
    private Map<String, Object> attrs;

    public RegistryEvent(ServiceRegistryReq serviceRegistryReq) {
        super(serviceRegistryReq.getMsgId());
        this.serviceInstanceType = serviceRegistryReq.getServiceInstanceType();
        this.username = serviceRegistryReq.getUsername();
        this.password = serviceRegistryReq.getPassword();
        this.ip = serviceRegistryReq.getIp();
        this.port = serviceRegistryReq.getPort();
        this.attrs = serviceRegistryReq.getAttrs();
    }

    public String getServiceInstanceType() {
        return serviceInstanceType;
    }

    public void setServiceInstanceType(String serviceInstanceType) {
        this.serviceInstanceType = serviceInstanceType;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public Map<String, Object> getAttrs() {
        return attrs;
    }

    public void setAttrs(Map<String, Object> attrs) {
        this.attrs = attrs;
    }
}
